﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Catalogo.Portable.ViewModel;
using Catalogo.Portable.ViewModel.Messages;

namespace Catalogo.WindowsPhone.Views
{
    public partial class FlyoutTexto : PhoneApplicationPage
    {
        public FlyoutTextoViewModel ViewModel
        {
            get
            {
                return DataContext as FlyoutTextoViewModel;
            }
        }

        public FlyoutTexto()
        {
            InitializeComponent();
        }

        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            var tipoFlyoutTexto = (TipoFlyoutTexto)Enum.Parse(typeof(TipoFlyoutTexto), NavegarParaPaginaMessageHandler.ObterParametro(e.Uri));
            if (ViewModel == null)
            {
                DataContext = new FlyoutTextoViewModel();
                ViewModel.Messenger.Subscribe<NavegarParaPagina>(NavegarParaPaginaMessageHandler.NavegarParaPagina);
                await ViewModel.LoadAsync(tipoFlyoutTexto);
            }
        }
    }
}